package com.dmjj.common.result;

import com.alibaba.fastjson.JSON;
import com.dmjj.common.vo.ResultPageVO;
import com.dmjj.common.vo.ResultVO;
import org.springframework.stereotype.Component;

/**
 * @author 张雪
 * @Description: 统一返回格式
 * @Title: ResultObject
 * @ProjectName dmjj-parent
 * @date 2018/12/24
 */
@Component
public class ResultPageObject {


    public ResultVO success(Integer code, String msg){
        ResultVO resultVO = new ResultVO(code,msg,null);
        return resultVO;
    }

    public ResultVO success(Integer code, String msg, Object object){
        ResultVO resultVO = new ResultVO(code,msg,object);
        return resultVO;
    }

    public ResultPageVO success(Integer code, String msg, Integer currentPage, Integer totalPage, Integer numPerPage, Integer totalCount, Boolean hasNext, Object json){
        ResultPageVO resultPageVO = new ResultPageVO(code,msg,currentPage,totalPage,numPerPage,totalCount,hasNext,json);
        return resultPageVO;
    }

    public ResultVO success(Integer code, String msg, JSON json){
        ResultVO resultVO = new ResultVO(code,msg,json);
        return resultVO;
    }

    public ResultPageVO error(Integer code, String msg){
        ResultPageVO ResultPageVO = new ResultPageVO(code,msg,null);
        return ResultPageVO;
    }

}

